<template>
  <div>
    <div class="box">
      <div
        class="bscroll"
        ref="bscroll"
      >
        <div
          class="bscroll-container"
          :style="{width: huachaungList.educationLIST.length*fenleiwidth+`px`}"
        >
          <div
            class="scroll_one"
            v-for="(item,index) in huachaungList.educationLIST"
            :key="index"
            @click="jiaoyudetail(item)"
          >
            <img
              :src="item.cover"
              alt
            >
            <div>{{item.name}}</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import BScroll from 'better-scroll'
export default {
  props: ['huachaungList'],
  data () {
    return {
      clientWidth: '',
      fenleiwidth: 0
    }
  },
  methods: {
    jiaoyudetail (item) {
      // console.log(item.curriculum_id)
      this.$emit('jiaoyudetail', item)
      // this.$router.push({ name: '/coursedetails', params: { curriculumId: item.curriculum_id } })
    }
  },
  components: {},
  created () {
  },
  mounted () {
    this.clientWidth = `${document.documentElement.clientWidth}`
    window.onresize = function temp () {
      this.clientHeight = `${document.documentElement.clientHeight}`
    }
    this.$nextTick(() => {
      let bscrollDom = this.$refs.bscroll
      this.aBScroll = new BScroll(bscrollDom, {
        scrollX: true
      })
    })
  },
  watch: {
    clientWidth: function () {
      this.fenleiwidth = parseInt(this.clientWidth) * 355 / 750
    }
  }
}
</script>
<style>
.bscroll {
  width: 100%;
  height: calc(100vw * 305 / 750 * 250 / 305);
  overflow: hidden;
}
.bscroll-container {
  white-space: nowrap;
  width: 100%;
}
.box {
  height: calc(100vw * 305 / 750 * 250 / 305);
  width: 100%;
  /* overflow: hidden; */
  position: relative;
}
.scroll-box {
  width: 100%;
  position: absolute;
  top: 0px;
  bottom: 0px;
  overflow: hidden;
  z-index: 1;
}
.scroll-box-content {
  display: inline-block;
  width: 100%;
  height: 100%;
  white-space: nowrap;
  position: absolute;
  top: 0;
  bottom: 0;
  overflow: hidden;
  z-index: 1;
}
.scroll_one:first-child {
  padding-left: calc(100vw * 38/750);
}
.scroll_one {
  display: inline-block;
  font-family: PingFangSC-Medium;
  font-size: 14px;
  font-weight: normal;
  font-stretch: normal;
  letter-spacing: 1px;
  color: #1a1a1a;
  margin-right: calc(100vw * 21 / 750);
}
.scroll_one > img {
  width: calc(100vw * 305 / 750);
  height: calc(100vw * 305 / 750 * 168 / 305);
  margin-bottom: calc(100vw * 305 / 750 * 10 / 305);
  border-radius: 4px;
}
.scroll_one > div {
  width: calc(100vw * 305 / 750);
  overflow: hidden;
  /* text-overflow: ellipsis; */
}
</style>
